package com.awesome.composedemo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview

class ListActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            val msgs = mutableListOf<Message>()
            val msg1 = Message("张三", "你好")
            val msg2 = Message("李四", "你好呀")
            val msg3 = Message("王五", "How are you?")
            val msg4 = Message("赵六", "Pretty good!And you?What are you doing recently?")
            msgs.add(msg1)
            msgs.add(msg2)
            msgs.add(msg3)
            msgs.add(msg4)
            Conversation(msgs)
        }
    }


}

@Composable
fun Conversation(messages: List<Message>) {
    LazyColumn {
        items(messages) { message ->
            MessageCard(msg = message)
        }
    }
}

@Preview
@Composable
fun PreviewConversation() {

}